package com.bocai.freeman.model.bean;


import org.greenrobot.eventbus.EventBus;

public class EventMessage {

    public enum State {
        SUCCESS, ERROR
    }

    public State what;
    public String message;
    public Object obj;

    public EventMessage setWhat(State what) {
        this.what = what;
        return this;
    }

    public EventMessage setMessage(String msg) {
        this.message = msg;
        return this;
    }

    public EventMessage setObj(Object obj) {
        this.obj = obj;
        return this;
    }

    public static void sendMessage(String message) {
        EventBus.getDefault().post(new EventMessage().setMessage(message));
    }

    public static void sendMessage(String message, Object obj) {
        EventBus.getDefault().post(new EventMessage().setMessage(message).setObj(obj));
    }

    public static void sendMessage(Object obj) {
        EventBus.getDefault().post(new EventMessage().setObj(obj));
    }

    public static void sendMessage(State state, String msg) {
        EventBus.getDefault().post(new EventMessage().setMessage(msg).setWhat(state));
    }

    public static void sendMessage(State state, String msg, Object obj) {
        EventBus.getDefault().post(new EventMessage().setMessage(msg).setWhat(state).setObj(obj));
    }

}
